<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>二维码标签打印</title>
    <style>
        @media print {
            body { margin: 0; }
            .no-print { display: none !important; }
            .qr-label { page-break-inside: avoid; }
        }
        
        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            margin: 20px;
            background: #f5f5f5;
        }
        
        .print-header {
            text-align: center;
            margin-bottom: 30px;
            padding: 20px;
            background: white;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        
        .print-header h1 {
            color: #333;
            margin: 0;
            font-size: 24px;
        }
        
        .qr-label {
            background: white;
            border: 2px solid #333;
            border-radius: 10px;
            padding: 20px;
            margin: 20px auto;
            max-width: 400px;
            text-align: center;
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        }
        
        .qr-code {
            margin: 20px 0;
        }
        
        .qr-code img {
            max-width: 200px;
            height: auto;
            border: 1px solid #ddd;
        }
        
        .task-info {
            margin: 20px 0;
            text-align: left;
        }
        
        .task-info table {
            width: 100%;
            border-collapse: collapse;
        }
        
        .task-info td {
            padding: 8px;
            border-bottom: 1px solid #eee;
        }
        
        .task-info td:first-child {
            font-weight: bold;
            color: #666;
            width: 80px;
        }
        
        .task-info td:last-child {
            color: #333;
        }
        
        .footer {
            margin-top: 20px;
            text-align: center;
            color: #666;
            font-size: 12px;
        }
        
        .print-buttons {
            text-align: center;
            margin: 20px 0;
        }
        
        .btn {
            display: inline-block;
            padding: 10px 20px;
            margin: 0 10px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 14px;
            text-decoration: none;
        }
        
        .btn-primary {
            background: #007bff;
            color: white;
        }
        
        .btn-success {
            background: #28a745;
            color: white;
        }
        
        .btn:hover {
            opacity: 0.8;
        }
        
        .company-info {
            background: #f8f9fa;
            padding: 15px;
            border-radius: 5px;
            margin: 20px 0;
            text-align: center;
        }
        
        .company-info h3 {
            margin: 0 0 10px 0;
            color: #333;
        }
        
        .company-info p {
            margin: 5px 0;
            color: #666;
        }
    </style>
</head>
<body>
    <div class="print-header no-print">
        <h1><i class="fa fa-qrcode"></i> 二维码标签打印</h1>
        <p>任务：{$allocation.order.order_no} - {$allocation.model.product.name} {$allocation.model.name} - {$allocation.process.name}</p>
    </div>
    
    <div class="print-buttons no-print">
        <button class="btn btn-primary" onclick="window.print()">
            <i class="fa fa-print"></i> 打印标签
        </button>
        <a href="scanwork/qrcode/download/{$allocation.id}" class="btn btn-success">
            <i class="fa fa-download"></i> 下载二维码
        </a>
        <button class="btn btn-default" onclick="window.close()">
            <i class="fa fa-times"></i> 关闭
        </button>
    </div>
    
    <div class="qr-label">
        <div class="company-info">
            <h3>工厂报工管理系统</h3>
            <p>生产任务二维码</p>
        </div>
        
        <div class="qr-code">
            <img src="{$qr_image}" alt="二维码">
        </div>
        
        <div class="task-info">
            <table>
                <tr>
                    <td>订单号：</td>
                    <td>{$allocation.order.order_no}</td>
                </tr>
                <tr>
                    <td>产品：</td>
                    <td>{$allocation.model.product.name}</td>
                </tr>
                <tr>
                    <td>型号：</td>
                    <td>{$allocation.model.name}</td>
                </tr>
                <tr>
                    <td>工序：</td>
                    <td>{$allocation.process.name}</td>
                </tr>
                <tr>
                    <td>员工：</td>
                    <td>{$allocation.user.nickname}</td>
                </tr>
                <tr>
                    <td>分配数量：</td>
                    <td>{$allocation.quantity}</td>
                </tr>
                <tr>
                    <td>待报数量：</td>
                    <td>{$allocation.remaining_quantity}</td>
                </tr>
                <tr>
                    <td>分配时间：</td>
                    <td>{:date('Y-m-d H:i', $allocation.createtime)}</td>
                </tr>
            </table>
        </div>
        
        <div class="footer">
            <p>扫描二维码快速报工 | 生成时间：{:date('Y-m-d H:i:s')}</p>
            <p>请将此标签贴在生产任务相关位置</p>
        </div>
    </div>
    
    <script>
        // 自动调整打印样式
        function adjustPrintStyle() {
            var style = document.createElement('style');
            style.textContent = `
                @media print {
                    body { 
                        margin: 0; 
                        background: white; 
                    }
                    .no-print { 
                        display: none !important; 
                    }
                    .qr-label { 
                        page-break-inside: avoid; 
                        box-shadow: none;
                        border: 1px solid #000;
                    }
                    .company-info {
                        background: #f0f0f0 !important;
                    }
                }
            `;
            document.head.appendChild(style);
        }
        
        // 页面加载完成后调整样式
        window.onload = function() {
            adjustPrintStyle();
        };
    </script>
</body>
</html> 